home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGNG_C / COLLECTC.LZH / _MAIN.C next >
Text File  |  1983-10-29  |  2KB  |  55 lines

  1. /** m20.c  --  defines _main for DOS 2.0   6.15.83
  2. *
  3. * This module defines a version of _main which processes the
  4. * command line for arguments and sets up _iob so that the first
  5. * three files defined are stdin, stdout, stderr which are opened
  6. * by DOS 2.0.  Re-direction is supported via DOS.
  7. * Stack size override is not supported.
  8. *
  9. *            Ted Reuss     c/o South Texas Software, Inc.
  10. *          Home: 713/961-3926      4544 Post Oak Place, Suite 176
  11. *          Offi: 713/877-8205      Houston, Tx 77027
  12. *
  13. **/
  14. #include <stdio.h>
  15. #define STDIN  0
  16. #define STDOUT 1
  17. #define STDERR 2
  18. #define MAXARG 32        /* maximum command line arguments */
  19.  
  20. _main(line)
  21. char *line;
  22. {
  23. static int argc = 0;
  24. static char *argv[MAXARG];
  25.  
  26. while (isspace(*line)) line++;    /* find program name */
  27. while (*line != '\0' && argc < MAXARG)
  28.    {            /* get command line parameters */
  29.    argv[argc++] = line;
  30.    while (*line != '\0' && isspace(*line) == 0) line++;
  31.    if (*line == '\0') break;
  32.    *line++ = '\0';
  33.    while (isspace(*line)) line++;
  34.    }
  35.  
  36. stdin->_flag |= _IONBF+_IOREAD;
  37. stdin->_file = STDIN;
  38. stdin->_base = stdin->_ptr = getmem(_BUFSIZ);
  39. stdin->_cnt  = 0;
  40.  
  41. stdout->_flag |= _IONBF+_IOWRT;
  42. stdout->_file = STDOUT;
  43. stdout->_base = stdout->_ptr = getmem(_BUFSIZ);
  44. stdout->_cnt  = 0;
  45.  
  46. stderr->_flag |= _IONBF+_IOWRT;
  47. stderr->_file = STDERR;
  48. stderr->_base = stderr->_ptr = getmem(_BUFSIZ);
  49. stderr->_cnt  = 0;
  50.  
  51. main(argc, argv);    /* call main function */
  52. }
  53. /** END M20 **/
  54. _base = stderr->_ptr = getmem(_BUFSIZ);
  55. stderr->_cnt  = 0